<?php

namespace App\Http\Controllers\Admin;



use App\Models\Good;
use Illuminate\Support\Facades\DB;

class ChooseHittypeController
{
    public function goodsList()
    {
        $search_keywords=request()->get('search_keywords');
        $model=Good::query()
            ->where('shelf_status','=',1);
        if(!empty($search_keywords)){
            $model=$model->where(function ($query) use($search_keywords) {
                $query->where('id', 'like', $search_keywords.'%')
                    ->orWhere('goods_name', 'like',$search_keywords.'%')
                    ->orWhere('num_iid', 'like',$search_keywords.'%');
            });
        }
        $goods=$model ->orderBy('id','desc')
            ->paginate(10);
        return view('admin.choose_hittype.goods_list',compact('goods','search_keywords'));
    }
    public function goodsCategory()
    {
        //$category=Category::query()->where('status','=',1)->orderBy('sort','desc')->paginate(10);
        $category = DB::select('select * from category where status = ? and level = ? ',[1,1]);
        //dd($category);
        return view('admin.choose_hittype.goods_category',compact('category'));
    }

    public function activity()
    {
        return view('admin.choose_hittype.activity');
    }
}